package cn.wolfcode.rbac.util;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.util.Collections;
import java.util.List;

@Setter
@Getter
public class PageResult {
    private List data;
    private int totalCount;
    private int currentPage;
    private int pageSize;
    private int totalPage;
    private int PrevPage;
    private int nextPage;

    public PageResult(List data, int totalCount, int currentPage, int pageSize) {
        this.data = data;
        this.totalCount = totalCount;
        this.pageSize = pageSize;
        this.currentPage = currentPage;
        this.totalPage = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
        this.PrevPage = currentPage > 1 ? currentPage - 1 : 1;
        this.nextPage = currentPage < this.totalPage ? currentPage + 1 : this.totalPage;

    }

    public PageResult(int currentPage, int pageSize) {
        this.data = Collections.EMPTY_LIST;
        this.totalCount = 0;
        this.currentPage = currentPage;
        this.pageSize = pageSize;

    }

}
